/*
 * 
 * 
 *    게시글 관련 function - board/boardItems  
 * 
 * 
 */

	function boardItemsView(itemsNo){
		
		alert(itemsNo);
	
		$.ajax({
			url: 'board.spring?action=boarditemsView' + '&boarditemsNo=' + itemsNo,
			method:'post',
			success:function(html) {
				$(".parsingPage").html(html);
			}
		});
	
	}
	
	

	function boardItemsPreAdd(boardNo){
	//    <c:if test="${login == null}">
	//    alert("로그인을 먼저 해주세요");
	//    </c:if>
	//    <c:if test="${login != null}">
	    $.ajax({
	        url: 'board.spring?action=boardItemsPreAdd&boardNo=' + boardNo,
	        method:'post',
	        success:function(html) {
	                $(".parsingPage").html(html);
	        }     
	    });
	}
	
	function boardItemsAdd(boardNo,data){
		$.ajax({
			url: 'board.spring?action=boardItemsAdd&boardNo=' + boardNo,
			method:'post',	
			data: $("#addForm").serialize(),
			success:function(html){
				$(".parsingPage").html(html);
			}
			
		});
	}
	
	
	function boardItemsPremodify(boardItemsNo){
		
		$.ajax({
	        url: 'board.spring?action=boardItemsPremodify' + '&boardItemsNo=' + boardItemsNo,
	        method:'post',
	        success:function(html) {
	                $(".parsingPage").html(html);
	        },            
	    });
		
	}
	function boardItemsModify(){
		
		$.ajax({
	        url: 'board.spring',
	        method:'post',
	        data: $("#boardmodifyForm").serialize() + '&action=boardItemsModify',
	        success:function(html) {
	                $(".parsingPage").html(html);
	        },         
	    });
		
	}
	
	function boardItemsRemove(boardItemsNo) {

		if(confirm("정말 삭제하시겠습니까???")) {
			
			$.ajax({
				url:'board.spring',
				method:'post',
				data: {action:'itemRemove', boardItemNo:itemNo},
				success:function(html) {
					$(".parsingPage" + boardItemsNo).hide();
				}
				
			});
		}
	}
	
	function itemsView(itemsNo){
		$.ajax({
			url: 'board.spring?action=itemsView',
			method:'post',
			success:function(html) {
				$(".parsingPage").html(html);
			},
		});
		
	}
	
	function boardList() {
		$.ajax({
			url : 'board.spring?action=boardList',
					
			success : function(html) {
				$("#navigation").html(html);
			}
		});
	}
	//////////////댓글//////////////
	function commentsadd(boarditemsNo){
		$.ajax({
			url:'board.spring?action=commentsadd',
			method:'post',
			data: $("#commentsaddForm_"+boarditemsNo).serialize(),
			success : function(html) {
				$("#commentList_"+boarditemsNo).html(html);
			}
			
		});
		
	}
	
	function commentsPreModify(commentsNo) {
		
		$.ajax({
			url:'board.spring',
			method:'post',
			data: 'commentsNo=' + commentsNo + '&action=commentsPreModify',
			success:function(html) {
				$("#commentsModify_" + commentsNo).html(html);
			}
			
		});
	}

	function commentsModify(commentsNo) {
		
		$.ajax({
			url:'board.spring',
			method:'post',
			data: $("#commentsModifyForm_" + commentsNo).serialize() + '&action=commentsModify',
			success:function(html) {
				$("#commentsView_" + commentsNo).html(html);
			}
			
		});
	}

	function commentsRemove(commentsNo, boarditemsNo) {
		
		if (!confirm('삭제 하시겠습니까?')) {
			return;
		}
		else {
			$.ajax({
				url:'board.spring',
				method:'post',
				data: 'commentsNo=' + commentsNo + '&boarditemsNo=' + boarditemsNo + '&action=commentsRemove',
				success:function(html) {
					$("#commentList_" + boarditemsNo).html(html);
				}
				
			});
		}
	}
	
	function commentsReply(commentsNo){
		$("#commentsReply_" + commentsNo).show();			
	}
	
	function commentsReplyAdd(commentsNo, boarditemsNo){
		$.ajax({
			url:'board.spring',
			method:'post',
			data: $("#commentsReplyForm_" + commentsNo).serialize() + "&action=commentsReplyAdd",
			success:function(html) {
				$("#commentList_" + boarditemsNo).html(html);
			}
			
		});
		
	}